package com.leo.base64;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 *
 * @author xuexiaolei
 * @version 2018年01月11日
 */
public class Test {
    public static void main(String[] args) {
        final String text = "Base64 finally in Java 8!";
        String encode = Base64.getEncoder().encodeToString(text.getBytes(StandardCharsets.UTF_8));
        System.out.println(encode);

        String decode = new String(Base64.getDecoder().decode(encode), StandardCharsets.UTF_8);
        System.out.println(decode);
    }
}
